import {ServerInfo} from "@/config/ServerInfoConfig.js";
import {useUserStore} from "@/store/index.js";
const userStore = useUserStore();
export const userTableOption = {
    stripe: true, //条纹
    addBtn: false,
    viewBtn: true,
    searchIndex: 3,
    searchIcon: true,
    height: '68vh',
    selection: true, //多选
    reserveSelection: true, //翻页多选
    index: true, //加序号
    showSummary: true, //展开底部求和
    menuType: 'icon', // 操作栏改为图标展示
    loadingText: "数据加载中...",
    emptyText: '数据空空如也...',
    column: [
        {label: '主键', prop: 'id', hide: true, display: false},
        {label: '用户名', prop: 'username', search: true},
        {
            label: '头像', prop: 'avatarUrl',
            type: 'upload',
            listType: 'picture-img',
            fileType: 'img',
            propsHttp: {
                res: 'data'
            },
            data: {
                userId: userStore.userInfo.id
            },
            tip: '只能上传jpg/png用户头像，且不超过500kb',
            action:`${ServerInfo.BASE_URL}/fileUpload/upload/single`,
        },
        {label: '用户账户', prop: 'account', search: true},
        {label: '用户邮箱', prop: 'email', search: true},
        {label: '手机号', prop: 'phone', search: true},
        {
            label: '用户角色', prop: 'role', display: false
        },
        {
            label: '用户角色', prop: 'roles',
            type: 'select', dicMethod: 'post',
            multiple: true, hide: true,
            props: {
                label: 'name',
                value: 'enName'
            },
            dicUrl: `${ServerInfo.BASE_URL}/userRole/list`,
        },
        {label: '用户地址', prop: 'address', hide: true},
        {
            label: '用户状态',
            prop: 'status',
            search: true,
            type: 'select',
            dicData: [
                {label: '正常', value: 0},
                {label: '暂停使用', value: 1}
            ]
        },
        {label: '备注', prop: 'remark', hide: true, search: true, type: 'textarea', span: 24},
        {label: '创建时间', prop: 'createTime', hide: true},
        {label: '创建人', prop: 'createUser', hide: true},
        {label: '更新时间', prop: 'updateTime', hide: true},
        {label: '更新人', prop: 'updateUser', hide: true},
        {label: '是否删除', prop: 'isDeleted', hide: true}
    ]
}

export const userFormOption = {
    labelWidth: 120,
    column: [
        {label: '用户名', prop: 'username',},
        {label: '用户账户', prop: 'account',},

        {label: '密码', prop: 'password',},
        {
            label: '用户角色', prop: 'roles',
            type: 'select', dicMethod: 'post',
            multiple: true,
            props: {
                label: 'name',
                value: 'enName'
            },
            dicUrl: `${ServerInfo.BASE_URL}/userRole/list`,
        },
        {label: '用户邮箱', prop: 'email',},
        {label: '手机号', prop: 'phone',},
        {
            label: '头像', prop: 'avatarUrl',
            type: 'upload',
            listType: 'picture-img',
            fileType: 'img',
            propsHttp: {
                res: 'data'
            },
            data: {
                userId: userStore.userInfo.id
            },
            tip: '只能上传jpg/png用户头像，且不超过500kb',
            action:`${ServerInfo.BASE_URL}/fileUpload/upload/single`,
        },
        {label: '用户地址', prop: 'address',},
        {
            label: '用户状态', prop: 'status',
            type: 'select',value:0,
            dicData: [
                {label: '正常', value: 0},
                {label: '暂停使用', value: 1}
            ]
        },
        {label: '备注', prop: 'remark', type: 'textarea', span: 24},
    ]
}

export const userInfoModifyCard = {
    labelWidth: 120,
    column: [
        {
            label: '昵称', prop: 'username', span: 24,
            rules: [{required: true, message: '请输入昵称', trigger: 'blur'}]
        },
        {
            label: '个人简介', prop: 'desc', span: 24, type: 'textarea',
            minRows: 3,
            maxRows: 3
        },
        {
            label: '修改密码', prop: 'password', search: true, span: 24
        },
    ]
}
